﻿/*  ----------------------------------------------------------------------------
 *  Microsoft Public License (http://www.microsoft.com/opensource/licenses.mspx#Ms-PL)
 *  
 *  ----------------------------------------------------------------------------
 *  DynamicAspect
 *  ----------------------------------------------------------------------------
 *  File:       Program.cs
 *  Author:     NiceWk (n9walker@hotmail.com)
 *  ----------------------------------------------------------------------------
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bizall.Dynamic.Aspect;
using System.Dynamic;
using System.Collections;

namespace BankSample
{
    class Program
    {
        static void Main(string[] args)
        {
  
           // Bank bank = new Bank();
            dynamic bank = new Bank().AsDynamic<Bank>();

            Console.WriteLine("========Desposit money from bank account=============");
            Console.WriteLine("Please enter deposit amount : ");
            decimal amount = 0;

            while (true)
            {
                string s = Console.ReadLine();
                if (decimal.TryParse(s, out amount))
                {
                    bank.Deposit(amount);
                    bank.ShowAccount();
                    break;
                }
                else
                {
                    Console.WriteLine("The amount is incorrect, please input again: ");
                }
            }

            Console.WriteLine("========Withdraw money from bank account=============");
            Console.WriteLine("Please enter withdraw amount : ");
            while (true)
            {
                string s = Console.ReadLine();
                if (decimal.TryParse(s, out amount))
                {
                    bank.Withdraw(amount);
                    bank.ShowAccount();
                    break;
                }
                else
                {
                    Console.WriteLine("The amount is incorrect, please input again: ");
                }
            }

            Console.ReadKey();
        }
    }
}